// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Create an AI medic
// -----------------------------------------------

private ["_unit","_men"];

_unit = _this select 0;

while { alive _unit } do {
	if (getDammage _unit > 0.10) then {
		_unit action ["heal", _unit];
		sleep 8;
	};

	_men = (getPosATL _unit) nearEntities ["CAManBase", 100];
	{
		if (_x in units(group _unit)) then {
			if (getDammage _x > 0.10) then {
				while {((position _unit distance position _x > 3) and (position _unit distance position _x < 100) and (alive _unit) and (alive _x))} do {
					_unit doMove position _x;
					sleep 10;
				};
				if ((alive _unit) and (alive _x)) then {
					_x action ["heal", _unit];
					sleep 8;
				};
			};
		};
	} foreach _men;
	sleep 1;
};